Skip to content

[KYUUBI #7407] STGroup free to avoid OOM Kill#7408

Open
oh0873 wants to merge 3 commits intoapache:masterfrom
oh0873:hoonoh/STTokenCleanups
Open

[KYUUBI #7407] STGroup free to avoid OOM Kill#7408
oh0873 wants to merge 3 commits intoapache:masterfrom
oh0873:hoonoh/STTokenCleanups

Conversation

@oh0873
Copy link
Copy Markdown

@oh0873 oh0873 commented Apr 16, 2026

Why are the changes needed?

When LDAP Authentication is used ST Token is created and saved in the cache, but it is never freed up.
This is causing continuous increase in heap usage, eventually causing out-of-memory for kyuubi server pods.

This changes is added to clear ST Tokens. Also ST Group is added to avoid any race condition during clean up.

How was this patch tested?

This patch was tested in our customer environment. We observed there's no more continuous heap increase after the fix.

Was this patch authored or co-authored using generative AI tooling?

Cursor auto-complete feature was used.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a heap growth/OOM issue in LDAP authentication by ensuring StringTemplate’s cached compiled templates/tokens don’t accumulate indefinitely.

Changes:

  • Instantiate ST with a per-query STGroup instead of the default group.
  • Unload the STGroup after rendering the LDAP search filter to release cached template state.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

oh0873 and others added 2 commits April 20, 2026 10:39
…ication/ldap/Query.scala


Spelling Fix

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
this.filterTemplate = new ST(filterTemplate)
val group = new STGroup()
this.filterTemplateGroup = Some(group)
this.filterTemplate = new ST(group, filterTemplate)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does cache only happen in filterTemplate.render?

what will happen if we call def filter multi times?

@@ -127,6 +131,8 @@
def build: Query = {
validate()
val filter: String = createFilter
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you update the def createFilter to add a () to the signature? because it actually has a side-effect.

require(filterTemplate != null, "filter is required for LDAP search query")
}

private def createFilter: String = filterTemplate.render
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add () for impure function

Suggested change
private def createFilter(): String = filterTemplate.render()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants